#include<iostream>
#include<queue>
#include <string>
using namespace std;
typedef struct node
{
    char data;
    struct node *lchild;
    struct node *rchild;
}*btree,btnode;
void CreateBTree(btree &bt,string str);
void printfbtree(btree bt);
int main()
{
      btree bt;
      bt=NULL;
      string str;
      cin>>str;
       CreateBTree(bt,str);
       printfbtree( bt);
}
void CreateBTree(btree &bt,string str)
{
    bt=new btnode;
    btree s;
    queue<btree>q;
    int i=0;
   if(str[0]!='#')
   {
      bt->data=str[0];
      q.push(bt);
   }
   else bt=NULL;

  while(q.size())
   {
       if(str[++i]=='#')
       {
           q.front()->lchild=NULL;
        //  q.pop();
       }
       else
        {
           s=new btnode;
           s->data=str[i];
           q.front()->lchild=s;
           q.push(q.front()->lchild);
       }
        if(str[++i]=='#')
        {
           q.front()->rchild=NULL;
        //  q.pop();
       }
       else
        {
           s=new btnode;
           s->data=str[i];
           q.front()->rchild=s;
           q.push(q.front()->rchild);
       }
       q.pop();
   }
}
void printfbtree(btree bt)
{
    queue<btree>q;
    q.push(bt);
    while(q.size())
    {
        cout<<q.front()->data<<" ";
        q.pop();
    }
}
